home *** CD-ROM | disk | FTP | other *** search
- ##############################################################################
- # begin.mml
- #
- # MailShield script that is run when the SMTP connection begins
- #
-
- ##############################################################################
- # (optional) log this connection
- #
- # &LogMessage("SMTP Connection received from: ".$PeerHostname." [".$PeerTcpip."] on ".$MyHostname." [".$MyTcpip."]");
-
-
- ##############################################################################
- # Check to see if the peer connected to us is listed as approved for relaying
- # in which case, we accept the connection and return immediately. We set the
- # $accept variable to TRUE so that some minimal tests are still performed
- # on the message (such as slowing down if too many recipients). If you want
- # to perform absolutely no more tests on this connection, then change "exit;"
- # to "&Accept;"
-
- # check the TCP/IP address to see if ok for relaying.
- if (&IpInArrayRange(@relay_ok_tcpip, $PeerTcpip)) {
- $accept = TRUE;
- &MessageAppend(" (TCP/IP address approved for relaying)");
- exit;
- };
-
- # check the hostname to see if OK for relaying.
- if (index(lc($PeerHostname), @relay_ok_hostnames) > -1) {
- $accept = TRUE;
- &MessageAppend(" (hostname approved for relaying)");
- exit;
- };
-
-
- ##############################################################################
- # check for banned TCP/IP range
-
- if (scalar(@banned_tcpip) > 0) {
- if (&IpInArrayRange(@banned_tcpip, $PeerTcpip)) {
- $smtp_message = "550 Message refused";
- $log_message = "550 Banned SMTP host TCP/IP address: ".$PeerTcpip." / matched ".$match;
- &DefaultRejection;
- };
- };
-
- ##############################################################################
- # check for banned domain names
-
- if (scalar(@banned_domains) > 0) {
- if (index(lc($PeerHostname), @banned_domains) > -1) {
- $smtp_message = "550 Message refused";
- $log_message = "550 Banned SMTP host domain name: ".$PeerHostname." / matched ".$match;
- &DefaultRejection;
- };
- };
-
- ##############################################################################
- # check to make sure this TCP/IP address has a valid Internet host name
-
- if ($reject_no_hostname) {
- if (length($PeerHostname) == 0) {
- $smtp_message = "550 Connection refused because no reverse DNS found for ".$PeerTcpip;
- $log_message = "550 TCP/IP address: ".$PeerTcpip." does not have a DNS hostname";
- &DefaultRejection;
- };
- };
-
-
- ##############################################################################
- # Check to see if this TCP/IP address is blacklisted using the RBL+ system
-
- if ($use_rbl_plus) {
- if (&DNSRBLLookup(".rbl-plus.mail-abuse.org", $PeerTcpip)) {
- $log_message = "550 SMTP session refused because your host tested positive on RBL+. See http://mail-abuse.org/rbl+/";
- $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RBL+. See http://mail-abuse.org/rbl+/";
- };
- }
-
- # If we are not using rbl+, check for other MAPS services
-
- else {
-
- ##############################################################################
- # Check to see if this TCP/IP address is blacklisted on the
- # Real-time Blackholing System (see http://maps.vix.com/rbl/ for info)
-
- if ($use_rbl) {
- if (&IsOnRbl($PeerTcpip)) {
- $log_message = "550 SMTP session refused because your host is listed on the RBL. See http://maps.vix.com/rbl/";
- $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RBL. See http://maps.vix.com/rbl/";
- &DefaultRejection;
- };
- };
-
- ##############################################################################
- # Check to see if this TCP/IP address is blacklisted on the
- # MAPS Relay Spam Stopper (RSS) (see http://www.mail-abuse.org/rss/ for info)
-
- if ($use_rss) {
- if (&DNSRBLLookup(".relays.mail-abuse.org", $PeerTcpip)) {
- $log_message = "550 SMTP session refused because your host is listed on the RSS. See http://www.mail-abuse.org/rss/";
- $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RSS. See http://www.mail-abuse.org/rss/";
- &DefaultRejection;
- };
- };
-
- ##############################################################################
- # Check to see if this TCP/IP address is blacklisted on the
- # MAPS DUL (see http://maps.vix.com/dul/ for info)
-
- if ($use_dul) {
- if (&DNSRBLLookup(".dialups.mail-abuse.org", $PeerTcpip)) {
- $log_message = "550 SMTP session refused because your host is listed on the DUL. See http://mail-abuse.org/dul/";
- $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the DUL. See http://mail-abuse.org/dul/";
- &DefaultRejection;
- };
- };
-
- };
-
- ##############################################################################
- # Check to see if this TCP/IP address is blacklisted on the
- # Open Relay Blocking System (ORBS) (see http://www.orbs.org for info)
-
- if ($use_orbs) {
- if (&DNSRBLLookup(".relays.orbs.org", $PeerTcpip)) {
- $log_message = "550 SMTP session refused because your host is listed on the ORBS. See http://www.orbs.org";
- $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the ORBS. See http://www.orbs.org";
- &DefaultRejection;
- };
- };
-
- ##############################################################################
- # check for tarpitted TCP/IP range
-
- if (scalar(@tarpit_addresses) > 0) {
- if (&IpInArrayRange(@tarpit_addresses, $PeerTcpip)) {
- $tarpit = TRUE;
- sleep($tarpit_delay);
- };
- };
-
- ##############################################################################
- # check for tarpitted domain names
-
- if (scalar(@tarpit_hostnames) > 0) {
- if (index(lc($PeerHostname), @tarpit_hostnames) > -1) {
- $tarpit = TRUE;
- sleep($tarpit_delay);
- };
- };
-
-
-